<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    <script>

        //1.扩展运算符可以将数组或者对象转换为用逗号分隔的参数序列
        let ary = ["a", "b", "c"];
        // ...ary  //"a","b","c"
        console.log(...ary);
        console.log("a", "b", "c");

        //2.扩展运算符应用-合并
        // let ary1 = [1, 2, 3];
        // let ary2 = [4, 5, 6];
        // let ary3 = [...ary1, ...ary2];
        // console.log(ary3);

        ////合并数组的第二种方法
        let ary1 = [1, 2, 3];
        let ary2 = [4, 5, 6];
        ary1.push(...ary2);
        console.log(ary1);


        //3.利用扩展运算符将伪数组转换成真正的数组
        var divs = document.getElementsByTagName('div');
        console.log(divs);  //打印伪数组
        const ary3 = [...divs]  //把伪数组转换成真正的数组，可以访问到数组中的方法
        console.log(ary3);
        ary3.push('aaa');
        console.log(ary3);

    </script>
</body>

</html>